package player;

import geography.Location;
import geography.Orientation;

import java.awt.image.BufferedImage;

public class Player {
	private Orientation facing;
	private Location position;
	private PlayerSprite sprite;
	
	public Player(Location startingPosition, Orientation initialFacing){
		if(startingPosition == null){
			throw new IllegalArgumentException("Player placement error!");
		}
		position = startingPosition;
		facing = initialFacing;
		sprite = new PlayerSprite(this);
	}
	
	/**
	 * Returns the direction the player is currently facing.
	 * @return {@link Orientation}
	 */
	public Orientation getFacing(){
		return facing;
	}
	
	/**
	 * Returns the player's position.
	 * @return {@link Location}
	 */
	public Location getPosition(){
		return position;
	}
	
	/**
	 * Moves the player to a new position.
	 * @param newPosition {@link Location}
	 */
	public void moveTo(Location newPosition){
		position = newPosition;
	}
	
	/**
	 * Changes the direction the {@link PlayerSprite} is facing.
	 * @param newFacing The new direction.
	 */
	public void changeFacing(Orientation newFacing){
		facing = newFacing;
	}
	
	/**
	 * Returns the current {@link PlayerSprite}'s image, according to which direction the player is facing.
	 * @return The {@link BufferedImage} of the player-character.
	 */
	public BufferedImage getImage(){
		return sprite.getImage();
	}

}
